package com.shop.www.model;

import java.math.BigDecimal;

public class CartItem {//购物车详情，一条详情为同一购物车的单种商品，即一个购物车有多个详情
    private Integer cartItem_ID;
    private Integer commodity_ID;
    private Integer buycount;
    private Integer user_ID;

    private Double money;

    private User buyer;
    private Commodity commodity;
    private boolean reducelock;
    private boolean addlock;

    public CartItem() {
    }

    public CartItem(Integer commodity_ID, Integer buycount, Integer user_ID) {
        this.commodity_ID = commodity_ID;
        this.buycount = buycount;
        this.user_ID = user_ID;
    }

    public CartItem(Integer cartItem_Id) {
        this.cartItem_ID = cartItem_Id;
    }

    public CartItem(Integer cartItem_Id, Integer commodity_ID, Integer buycount, Integer user_ID) {
        this.cartItem_ID = cartItem_Id;
        this.commodity_ID = commodity_ID;
        this.buycount = buycount;
        this.user_ID = user_ID;
    }

    public CartItem(Integer cartItem_ID, Integer buycount) {
        this.cartItem_ID = cartItem_ID;
        this.buycount = buycount;
    }

    public Integer getCartItem_ID() {
        return cartItem_ID;
    }

    public void setCartItem_ID(Integer cartItem_ID) {
        this.cartItem_ID = cartItem_ID;
    }

    public Integer getCommodity_ID() {
        return commodity_ID;
    }

    public void setCommodity_ID(Integer commodity_ID) {
        this.commodity_ID = commodity_ID;
    }


    public Integer getBuycount() {
        return buycount;
    }

    public void setBuycount(Integer buycount) {
        this.buycount = buycount;
    }

    public Integer getUser_ID() {
        return user_ID;
    }

    public void setUser_ID(Integer user_ID) {
        this.user_ID = user_ID;
    }

    public Double getMoney() {
        BigDecimal bigDecimalPrice = new BigDecimal(""+getCommodity().getPrice());
        BigDecimal bigDecimalBuycount = new BigDecimal(""+buycount);
        BigDecimal bigDecimalmoney = bigDecimalPrice.multiply(bigDecimalBuycount);
        money = bigDecimalmoney.doubleValue();
        return money;
    }

    public void setMoney(Double money) {
        this.money = money;
    }

    public User getBuyer() {
        return buyer;
    }

    public void setBuyer(User buyer) {
        this.buyer = buyer;
    }

    public Commodity getCommodity() {
        return commodity;
    }

    public void setCommodity(Commodity commodity) {
        this.commodity = commodity;
    }

    public boolean isReducelock() {
        return reducelock;
    }

    public void setReducelock(boolean reducelock) {
        this.reducelock = reducelock;
    }

    public boolean isAddlock() {
        return addlock;
    }

    public void setAddlock(boolean addlock) {
        this.addlock = addlock;
    }
}
